import imghdr
import oss2

def check_img(data):
    info = imghdr.what(data)
    if not info:
        raise ValueError("请上传图片")
    return data


def up_img(data,name):
    auth = oss2.Auth('LTAI5tJYcTkHpDQgR46wXPkm', 'wqwFxH0MdTl5LurgkDyQ6NT6nrOrea')
    bucket = oss2.Bucket(auth, 'https://oss-cn-hangzhou.aliyuncs.com', 'yunflask')
    info = bucket.put_object(name, data)